package com.sky.controller.admin;

import com.sky.dto.*;
import com.sky.entity.Category;
import com.sky.entity.Employee;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import com.sky.service.SetmealService;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 菜品管理
 */
@RestController
@RequestMapping("/admin/category")
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/page")
    @ApiOperation("分类分页查询")
    public Result<PageResult> page(CategoryPageQueryDTO categoryPageQueryDTO) {
        log.info("分类分页查找：{}", categoryPageQueryDTO);
        PageResult pageResult=  categoryService.pageselect(categoryPageQueryDTO);


        return Result.success(pageResult);
    }
    /**
     * 启用员工
     * @param status
     * @param id
     * @return
     */
    @PostMapping("/status/{status}")
    @ApiOperation("启用禁用套餐")
    public Result<String > enableDisable(@PathVariable int status,long id) {
        log.info("套餐启用和增加：{},{}", status,id);
        categoryService.enDi(status,id);



        return Result.success();
    }
    /**
     *员工增加
     * @param categoryDTO
     * @return
     */
    @PostMapping
    @ApiOperation("添加员工")
    public Result<String > add(@RequestBody CategoryDTO categoryDTO) {
        log.info("员工跟新：{}", categoryDTO);
        categoryService.add(categoryDTO);

        return Result.success();
    }

    /**
     *根据id查询数据
     * @param type
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("type查询分类")
    public Result<Category> selectIdsEmploye(Integer type) {
        log.info("查询分类：{}", type);

        Category category= categoryService.selectIdscate(type);

        return Result.success(category);
    }

    @PutMapping
    @ApiOperation("菜品跟新")
    public Result<String > update(@RequestBody  CategoryDTO categoryDTO) {
        log.info("菜品跟新：{}", categoryDTO);
        categoryService.update(categoryDTO);




        return Result.success();
    }
    @DeleteMapping
    @ApiOperation("通过id删除菜品")
    public Result<String > update(Integer id) {
        log.info("菜品id：{}", id);
        categoryService.delete(id);




        return Result.success();
    }

}
